//
//  BYJMVTableViewCell.m
//  BLDMusics
//
//  Created by 白云杰 on 16/3/19.
//  Copyright © 2016年 李晓丹. All rights reserved.
//

#import "BYJMVTableViewCell.h"

@interface BYJMVTableViewCell ()

@property (nonatomic, retain) UIImageView *picImageView;
@property (nonatomic, retain) UILabel *titleLabel;
@property (nonatomic, retain) UILabel *nameLabel;
@property (nonatomic, retain) UIImageView *browserImgView;
@property (nonatomic, retain) UILabel *browserLabel;
@property (nonatomic, retain) UIImageView *commentImgView;
@property (nonatomic, retain) UILabel *commentLabel;

@end

@implementation BYJMVTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self= [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCell];
    }
    return self;
}

- (void)setModel:(BYJMVModel *)model {
    _model = model;
    [self assignment];
}

- (void)createCell {
    
    self.picImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:_picImageView];
    
    self.titleLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_titleLabel];
    
    self.nameLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_nameLabel];
    
    self.browserImgView = [[UIImageView alloc] init];
    [self.contentView addSubview:_browserImgView];
    
    self.browserLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_browserLabel];
    
    self.commentImgView = [[UIImageView alloc] init];
    [self.contentView addSubview:_commentImgView];
    
    self.commentLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_commentLabel];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    _picImageView.frame = CGRectMake(5, 5, (self.contentView.frame.size.height - 10) * 768 / 432, self.contentView.frame.size.height - 10);
    CGSize size = [APPTools labelRectWithSize:CGSizeMake(0, 0) labelText:_model.videoName Font:[UIFont systemFontOfSize:20]];
    _titleLabel.frame = CGRectMake((self.contentView.frame.size.height - 10) * 768 / 432 + 10, 10, size.width, size.height);
    
    _nameLabel.frame = CGRectMake((self.contentView.frame.size.height - 10) * 768 / 432 + 10, size.height + 15, 100, 20);
    _nameLabel.font = [UIFont systemFontOfSize:13];
    
    _browserImgView.frame = CGRectMake((self.contentView.frame.size.height - 10) * 768 / 432 + 10, size.height + 40, 20, 20);
    
    _browserLabel.frame = CGRectMake((self.contentView.frame.size.height - 10) * 768 / 432 + 35, size.height + 40, 60, 20);
    _browserLabel.font = [UIFont systemFontOfSize:13];
    
    _commentImgView.frame = CGRectMake((self.contentView.frame.size.height - 10) * 768 / 432 + 110, size.height + 40, 20, 20);
    _commentLabel.frame =  CGRectMake((self.contentView.frame.size.height - 10) * 768 / 432 + 135, size.height + 40, 60, 20);
    _commentLabel.font = [UIFont systemFontOfSize:13];
}

- (void)assignment {
    BYJmvListModel *model = _model.mvListArr[0];
        [_picImageView sd_setImageWithURL:[NSURL URLWithString:model.picUrl] placeholderImage:PLACEHOLDER];
    _titleLabel.text = _model.videoName;
    _nameLabel.text = _model.singerName;
    _browserImgView.image = [UIImage imageNamed:@"timeLineMessageforward"];
    _browserLabel.text = [NSString stringWithFormat:@"%@", _model.pickCount];
    _commentImgView.image = [UIImage imageNamed:@"timeLineMessageComment"];
    _commentLabel.text = [NSString stringWithFormat:@"%@", _model.bulletCount];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
